﻿using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Models.JsonResultModel;
using System;
using System.Diagnostics;
using GatewayServer.Common;
using GatewayServer.Models;
using ServiceWeb.APIRequest;
using UtilsBase;

namespace GatewayServer.Controllers
{
    public class HomeController : Controller
    {
        private readonly ILogger<HomeController> _logger;

        public HomeController(ILogger<HomeController> logger)
        {
            _logger = logger;
        }
        public RespResultData sendsql()
        {
            new ServiceDeviceControlRemote().senddatasql("100", "iot_device", "select * from iot_device", " - ");
            new ServiceDeviceControlRemote().senddatasql("100", "iot_device_command", "select * from iot_device_command", " - ");
            new ServiceDeviceControlRemote().senddatasql("100", "iot_device_command_log", "select * from iot_device_command_log", " - ");
            new ServiceDeviceControlRemote().senddatasql("100", "iot_mq_log", "select * from iot_mq_log", " - ");
            new ServiceDeviceControlRemote().senddatasql("100", "iot_device_value_log", "select * from iot_device_value_log", " - ");
            new ServiceDeviceControlRemote().senddatasql("100", "iot_device_value_current", "select * from iot_device_value_current", " - ");
            new ServiceDeviceControlRemote().senddatasql("100", "iot_device_model", "select * from iot_device_model", " - ");
            new ServiceDeviceControlRemote().senddatasql("100", "iot_device_gateway", "select * from iot_device_gateway", " - ");
            return RespResult.Sucess();
        }
        public RespResultData sendDeviceCommand()
        {
            new ServiceDeviceControlRemote().sendDeviceCommand("100", "B64F1144-E77C-4490-A69E-97A3EFE5034933", "open", "", "");
            return RespResult.Sucess();
        }

        public IActionResult Index()
        {
            return View();
        }

        public IActionResult Privacy()
        {
            return View();
        }

        [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
        public IActionResult Error()
        {
            return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
        }
    }
}